package com.tcr.action;

import java.util.List;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.tcr.common.TcCov;
import com.tcr.common.TcProject;
import com.tcr.common.TcUser;
import com.tcr.dao.CoverageDao;
import com.tcr.dao.ProjectMapDao;

public class HomeAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public String uploadform() {
		TcUser tc_user = (TcUser) ActionContext.getContext().getSession().get(
				"user");
		this.setUser(tc_user);
		List<TcProject> tc_projs = ProjectMapDao.getProjsByUid(tc_user.uid);
		this.setProjs(tc_projs);
		return Action.SUCCESS;
	}

	public String myproject() {
		TcUser tc_user = (TcUser) ActionContext.getContext().getSession().get(
				"user");
		this.setUser(tc_user);
		List<TcProject> tc_projs = ProjectMapDao.getProjsByUid(tc_user.uid);
		this.setProjs(tc_projs);
		return Action.SUCCESS;
	}

	public String checkcov() {
		int pid = Integer.parseInt(this.getPid().trim());
		List<TcCov> m_covs = CoverageDao.getCovByPid(pid);
		System.out.println(m_covs.size());
		this.setCovs(m_covs);
		return Action.SUCCESS;
	}

	private String pid;
	private List<TcCov> covs;
	public TcUser user;
	public List<TcProject> projs;

	public List<TcProject> getProjs() {
		return projs;
	}

	public void setProjs(List<TcProject> projs) {
		this.projs = projs;
	}

	public TcUser getUser() {
		return user;
	}

	public void setUser(TcUser user) {
		this.user = user;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	public String getPid() {
		return pid;
	}

	public void setCovs(List<TcCov> covs) {
		this.covs = covs;
	}

	public List<TcCov> getCovs() {
		return covs;
	}
}
